home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1998 August / PC Plus SuperCD 50a Issue 142 (CD142a) (August 1998).iso / trial / demon / TURNPIKE.1 / CLASSES.ZIP / JAVA / IO / File.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-04-14  |  3.3 KB  |  222 lines

  1. package java.io;
  2.  
  3. import java.util.Vector;
  4.  
  5. public class File {
  6.    private String path;
  7.    public static final String separator = System.getProperty("file.separator");
  8.    public static final char separatorChar;
  9.    public static final String pathSeparator;
  10.    public static final char pathSeparatorChar;
  11.  
  12.    public File(String var1) {
  13.       if (var1 == null) {
  14.          throw new NullPointerException();
  15.       } else {
  16.          this.path = var1;
  17.       }
  18.    }
  19.  
  20.    public File(String var1, String var2) {
  21.       this(var1 != null ? var1 + separator + var2 : var2);
  22.    }
  23.  
  24.    public File(File var1, String var2) {
  25.       this(var1.getPath(), var2);
  26.    }
  27.  
  28.    public String getName() {
  29.       String var1 = this.path;
  30.       char var2 = separatorChar;
  31.       int var4 = var1.lastIndexOf(var2, var1.count - 1);
  32.       if (var4 < 0) {
  33.          return this.path;
  34.       } else {
  35.          String var5 = this.path;
  36.          int var3 = var4 + 1;
  37.          return var5.substring(var3, var5.count);
  38.       }
  39.    }
  40.  
  41.    public String getPath() {
  42.       return this.path;
  43.    }
  44.  
  45.    public String getAbsolutePath() {
  46.       return this.isAbsolute() ? this.path : System.getProperty("user.dir") + separator + this.path;
  47.    }
  48.  
  49.    public String getParent() {
  50.       String var1 = this.path;
  51.       char var2 = separatorChar;
  52.       int var3 = var1.lastIndexOf(var2, var1.count - 1);
  53.       return var3 <= 0 ? null : this.path.substring(0, var3);
  54.    }
  55.  
  56.    private native boolean exists0();
  57.  
  58.    private native boolean canWrite0();
  59.  
  60.    private native boolean canRead0();
  61.  
  62.    private native boolean isFile0();
  63.  
  64.    private native boolean isDirectory0();
  65.  
  66.    private native long lastModified0();
  67.  
  68.    private native long length0();
  69.  
  70.    private native boolean mkdir0();
  71.  
  72.    private native boolean renameTo0(File var1);
  73.  
  74.    private native boolean delete0();
  75.  
  76.    private native String[] list0();
  77.  
  78.    public boolean exists() {
  79.       SecurityManager var1 = System.security;
  80.       if (var1 != null) {
  81.          var1.checkRead(this.path);
  82.       }
  83.  
  84.       return this.exists0();
  85.    }
  86.  
  87.    public boolean canWrite() {
  88.       SecurityManager var1 = System.security;
  89.       if (var1 != null) {
  90.          var1.checkWrite(this.path);
  91.       }
  92.  
  93.       return this.canWrite0();
  94.    }
  95.  
  96.    public boolean canRead() {
  97.       SecurityManager var1 = System.security;
  98.       if (var1 != null) {
  99.          var1.checkRead(this.path);
  100.       }
  101.  
  102.       return this.canRead0();
  103.    }
  104.  
  105.    public boolean isFile() {
  106.       SecurityManager var1 = System.security;
  107.       if (var1 != null) {
  108.          var1.checkRead(this.path);
  109.       }
  110.  
  111.       return this.isFile0();
  112.    }
  113.  
  114.    public boolean isDirectory() {
  115.       SecurityManager var1 = System.security;
  116.       if (var1 != null) {
  117.          var1.checkRead(this.path);
  118.       }
  119.  
  120.       return this.isDirectory0();
  121.    }
  122.  
  123.    public native boolean isAbsolute();
  124.  
  125.    public long lastModified() {
  126.       SecurityManager var1 = System.security;
  127.       if (var1 != null) {
  128.          var1.checkRead(this.path);
  129.       }
  130.  
  131.       return this.lastModified0();
  132.    }
  133.  
  134.    public long length() {
  135.       SecurityManager var1 = System.security;
  136.       if (var1 != null) {
  137.          var1.checkRead(this.path);
  138.       }
  139.  
  140.       return this.length0();
  141.    }
  142.  
  143.    public boolean mkdir() {
  144.       SecurityManager var1 = System.security;
  145.       if (var1 != null) {
  146.          var1.checkWrite(this.path);
  147.       }
  148.  
  149.       return this.mkdir0();
  150.    }
  151.  
  152.    public boolean renameTo(File var1) {
  153.       SecurityManager var2 = System.security;
  154.       if (var2 != null) {
  155.          var2.checkWrite(this.path);
  156.          var2.checkWrite(var1.path);
  157.       }
  158.  
  159.       return this.renameTo0(var1);
  160.    }
  161.  
  162.    public boolean mkdirs() {
  163.       if (this.mkdir()) {
  164.          return true;
  165.       } else {
  166.          String var1 = this.getParent();
  167.          return var1 != null && (new File(var1)).mkdirs() && this.mkdir();
  168.       }
  169.    }
  170.  
  171.    public String[] list() {
  172.       SecurityManager var1 = System.security;
  173.       if (var1 != null) {
  174.          var1.checkRead(this.path);
  175.       }
  176.  
  177.       return this.list0();
  178.    }
  179.  
  180.    public String[] list(FilenameFilter var1) {
  181.       String[] var2 = this.list();
  182.       Vector var3 = new Vector();
  183.  
  184.       for(int var4 = 0; var4 < var2.length; ++var4) {
  185.          if (var1 == null || var1.accept(this, var2[var4])) {
  186.             var3.addElement(var2[var4]);
  187.          }
  188.       }
  189.  
  190.       String[] var5 = new String[var3.elementCount];
  191.       var3.copyInto(var5);
  192.       return var5;
  193.    }
  194.  
  195.    public boolean delete() {
  196.       SecurityManager var1 = System.security;
  197.       if (var1 != null) {
  198.          var1.checkDelete(this.path);
  199.       }
  200.  
  201.       return this.delete0();
  202.    }
  203.  
  204.    public int hashCode() {
  205.       return this.path.hashCode() ^ 1234321;
  206.    }
  207.  
  208.    public boolean equals(Object var1) {
  209.       return var1 != null && var1 instanceof File ? this.path.equals(((File)var1).path) : false;
  210.    }
  211.  
  212.    public String toString() {
  213.       return this.getPath();
  214.    }
  215.  
  216.    static {
  217.       separatorChar = separator.charAt(0);
  218.       pathSeparator = System.getProperty("path.separator");
  219.       pathSeparatorChar = pathSeparator.charAt(0);
  220.    }
  221. }
  222.